/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csse3004.GD.WBUser;

import csse3004.GD.DA.WBUserDA;
import csse3004.GD.Poll;
import java.util.ArrayList;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author Lan Ye 42239015
 */
public class homeController implements Controller {

    private WBUserService WBUserService = new WBUserDA();
    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
        ArrayList<Poll> pollList = new ArrayList<Poll>();
        //pollList = new Poll().genTestPoll();//Dummy
        int userID = Integer.parseInt((String) hsr.getSession().getAttribute("userID"));
        pollList = WBUserService.getPolls(userID);
        return new ModelAndView("home", "polls", pollList);

    }
}
